package service

import (
	"guliedu/model"
	"guliedu/repository"
)

type IUCenterMemberService interface {
	Insert(member *model.UCenterMember) error
	Select(username string) (*model.UCenterMember, error)
	MemberSendEmail(to string)
	GetMemberCode(email string) (string, error)
}

func NewIUCenterMemberService() IUCenterMemberService {
	return &UCenterMemberService{UCenterMemberRepository: repository.NewIUCenterMemberRepository()}
}

type UCenterMemberService struct {
	UCenterMemberRepository repository.IUCenterMemberRepository
}

func (t *UCenterMemberService) Insert(member *model.UCenterMember) error {
	return t.UCenterMemberRepository.Insert(member)
}

func (t *UCenterMemberService) Select(username string) (*model.UCenterMember, error) {
	return t.UCenterMemberRepository.Select(username)
}

func (t *UCenterMemberService) MemberSendEmail(to string) {
	t.UCenterMemberRepository.MemberSendEmail(to)
}

func (t *UCenterMemberService) GetMemberCode(email string) (string, error) {
	return t.UCenterMemberRepository.GetMemberCode(email)
}
